const api = require('../index')

module.exports = {
  getToken: (code, nickname, head_img) => {
    return api.post('/user/authorize', { code, nickname, head_img })
  },
	wxdecrypt: (encrypted_data, iv, type = '') => {
    // 如果 type = ‘phone’，后端解密出手机号后，会更新到user表
		return api.post('/sns/wxdecrypt', { encrypted_data, iv, type})
	}, 
	wxdecryptWithNoLogin: (encrypted_data, iv, token = '') => {
		// 如果 type = ‘phone’，后端解密出手机号后，会更新到user表
		return api.post('/sns/wxdecryptWithNoLogin', { encrypted_data, iv, token })
	},
	wxLogin: (token, unionid, nickname, head_img_url, gender, city, province, country, client_type, phone_model, os, screen_height, screen_width, network_type) => {
		return api.post('/sns/wxLogin', { token, unionid, nickname, head_img_url, gender, city, province, country, client_type, phone_model, os, screen_height, screen_width, network_type })
  },
  sendVerifyCode: (phone) => {
    return api.post('/sns/sendVerifyCode', { phone })
  },
  phoneBind: (code, phone) => {
    return api.post('/sns/phoneBind', { code, phone })
  },
  weChatCode: (scene, page, width) => {
    return api.post('/sns/wxqrcode', { scene, page, width })
  },
	contactTap: (openid, nickname, head_img_url) => {
		return api.post('/service/start', { openid, nickname, head_img_url })
	}
}